require "lua_test.lua_map.map.scripts.tools.printx"
require "lua_test.lua_map.map.scripts.constant.enum"

require "lua_test.lua_map.map.scripts.tools.math"

-- 256
local v=12
local r={}
while(v>0) do
    local tmp=v%2
    v=v//2
    table.insert(r,tmp)
end


for i=1,16 do
    local binAblv=r[i] or -1
    --print(binAblv)
end    

local str="a-677"
local firstStr=string.sub(str,1,1)
local strsub=string.gsub(str,firstStr,"")
print(firstStr)
print(strsub)
local v=tonumber(strsub)
print(v)

if(firstStr=="a") then
    print("atk")
elseif (firstStr=="d") then
    print("def")
elseif (firstStr=="s") then
    print("aspd")
end

print(UNIT_FIELD_CONFIG.str.binary_rel_set)


local mmx={
    name="测试小刀",
    lvl=7,
    field={
       atk=-100,
       def=100,
       hp=600
    }
}

-- for i,v in pairs(mmx.field) do
--     --incrUnitFieldByHandle(tunit,i,-1*v)
--     print(i.."="..v)
-- end    


local item_config=require "lua_test.lua_map.map.scripts.config.item_config"

local cur_item_config=item_config["I01O"]
if cur_item_config~=nil and cur_item_config.field~=nil then
    printTable(cur_item_config.field)
    for i,v in pairs(cur_item_config.field) do
        --incrUnitFieldByHandle(tunit,i,-1*v)
        print(i.."="..v)
    end    
end    

local angle=getAngle(0,0,1,1)
print("???"..angle)
local ag2=getAngle(0,0,0,2)
print("???"..ag2)


local width=1.4142
local length=1.4142

local p1=getDisLocXY(1,1,angle+90,width/2)
local p2=getDisLocXY(1,1,angle-90,width/2)
local p3=getDisLocXY(p2.x,p2.y,angle,length)
local p4=getDisLocXY(p1.x,p1.y,angle,length)



-- printTable(p1)
-- printTable(p2)
-- printTable(p3)
-- printTable(p4)

local p={x=1.1,y=-0.1}

--printTable((GetCross(p1, p2, p) * GetCross(p3, p4, p) >= 0 ) and (GetCross(p2, p3, p) * GetCross(p4, p1, p) >= 0))

printTable(xyInRect(p.x,p.y,0,0,1,1,1.4142,1.4142))


-- require "lua_test.lua_map.map.scripts.class.itemx"
-- local nitem=addItemField(12567,{field={atk=50,def=50,mp=300}})
-- printTable(nitem)

--printTable(r)

